﻿using RazorEngine;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox2.Text = EncryptUtils.DESEncode(textBox1.Text);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox3.Text = EncryptUtils.DESDecode(textBox2.Text);
        }

        //private void button3_Click(object sender, EventArgs e)
        //{

        //    var destination = new Destination
        //    {
        //        Country = "Indonesia",
        //        Description = "EcoTourism at its best in exquisite Bali",
        //        Name = "Bali何潮"
        //    };
        //    using (var context = new BreakAwayContext())
        //    {
        //        context.Destinations.Add(destination);
        //        MessageBox.Show(context.SaveChanges().ToString());
        //    }
        //}

      

        

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            string template = "Hello @Model.Name! Welcome to Razor!";
            string result = Razor.Parse(template, new { Name = "World" });
            MessageBox.Show(result);

            string template1 = @"@{  
    if(@Model.age>10)  
    {  
       0;
    }  
    else  
    {  
       1;
    }  
}";
            string result1 = Razor.Parse(template1, new { age = 10 });
            MessageBox.Show(result1);

            
//            string template1 =
//  @"<html>
//      <head>
//        <title>Hello @Model.Name</title>
//      </head>
//      <body>
//        Email: @Html.TextBoxFor(m => m.Email)
//      </body>
//    </html>";

//            var model = new PageModel { Name = "World", Email = "someone@somewhere.com" };
//            string result1 = Razor.Parse(template1, model);
//            MessageBox.Show(result1);
            // dynamic ViewBag = new DynamicViewBag(); ViewBag.list = “流年莫逝”; string template = “Hello Word @ViewBag.list”;
            //string result = Razor.Parse(template,null,ViewBag,Guid.NewGuid().ToString());
        }
      
    


    }
}
            
